package com.fl.nettydemo.c3;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.*;

/**
 * jdk的future 一般在线程池中使用
 */
@Slf4j
public class TestFutureTask {
    @SneakyThrows
    public static void main(String[] args) {
        ExecutorService service = Executors.newFixedThreadPool(2);
        Future<Integer> future = service.submit((Callable<Integer>) () -> {
            log.info("执行future任务");
            return 50;
        });

        log.info("等待结果");
        log.info("结果为-》:{}",future.get());
    }
}
